'use strict';

/**
 * @param {Egg.Application} app - egg application
 */

module.exports = app => {
    const { router, controller } = app;
    const auth = app.middleware.auth;
    // 菜单管理   
    router.post("/sys/addMenu", auth("menu:add"), controller.sys.menu.addMenu);
    router.get("/sys/getMenuTree", auth("menu:search"), controller.sys.menu.getMenuTree);
    router.get("/sys/getMenus", auth("menu:search"), controller.sys.menu.getMenus);
    router.delete("/sys/deleteMenu", auth("menu:delete"), controller.sys.menu.deleteMenu);
    router.put("/sys/updateMenu", auth("menu:update"), controller.sys.menu.updateMenu);

    // 用户管理
    router.post("/login", controller.sys.user.login);
    router.post("/sys/addUser", auth("user:add"), controller.sys.user.addUser);
    router.get("/sys/getUserInfo", auth("user:search"), controller.sys.user.getInfo);
    router.get("/sys/getUsers", auth("user:search"), controller.sys.user.getUsers);
    router.delete("/sys/deleteUser", auth("user:delete"), controller.sys.user.deleteUser);
    router.put("/sys/updateUser", auth("user:update"), controller.sys.user.updateUser);

    router.post("/sys/updateAuthority", auth("user:update"), controller.sys.user.updateAuthority);
    router.get("/sys/getUserAuthority", auth("user:search"), controller.sys.user.getUserAuthority);

    // 角色管理 
    router.post("/sys/addRole", auth("role:add"), controller.sys.role.addRole);
    router.get("/sys/getRoles", auth("role:search"), controller.sys.role.getRoles);
    router.get("/sys/getRole", auth("role:search"), controller.sys.role.getRole);
    router.put("/sys/updateRole", auth("role:update"), controller.sys.role.updateRole);
    router.delete("/sys/deleteRole", auth("role:delete"), controller.sys.role.deleteRole);

    router.post("/file/upload", controller.sys.file.uploadFile);
    router.delete("/file/delete", controller.sys.file.deleteFile);


};




